package top.luo.sqlSession;

import org.dom4j.DocumentException;
import top.luo.config.XmlConfigBuilder;
import top.luo.pojo.Configuration;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * @author luo
 * @date 2021-01-04 20:54
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream ins) throws DocumentException, PropertyVetoException {
        // 1. 解析配置文件，将解析后的内容封装到 Configuration 中
        XmlConfigBuilder configBuilder = new XmlConfigBuilder();
        Configuration configuration = configBuilder.parse(ins);


        // 2. 创建 SqlSessionFactory 对象
        return new DefaultSqlSessionFactory(configuration);
    }

}
